<h1 mat-dialog-title>Set User Role</h1>
<form [formGroup]="userRoleForm" (submit)="onSubmit()">
    <div mat-dialog-content>

        <mat-progress-bar mode='indeterminate' *ngIf='loading'></mat-progress-bar>
        <mat-form-field class="full-width-input">
            <mat-label>Id</mat-label>
          <input matInput formControlName="id">
        </mat-form-field>

        <mat-form-field class="full-width-input">
          <mat-label>Username</mat-label>
          <input matInput
            formControlName="userName">
        </mat-form-field>
        <mat-form-field class="full-width-input">
          <mat-select placeholder="Role" formControlName="roleName" required>
            <mat-option *ngFor="let role of userRoles" [value]="role">
              {{role}}
            </mat-option>
          </mat-select>
          <mat-error *ngIf="isFieldInvalid('roleName', 'required')">
            Please select a role
          </mat-error>
        </mat-form-field>
      </div>
      <div mat-dialog-actions>
          <button mat-button cdkFocusInitial *ngIf="!editing" (click)="onEditClick()">Edit</button>
          <button mat-button cdkFocusInitial *ngIf="editing">Save</button>
          <button mat-button [mat-dialog-close]="false" *ngIf="!editing">Close</button>
          <button mat-button *ngIf="editing" (click)="onCancelClick()">Cancel</button>
      </div>
</form>
